﻿@using Microsoft.JSInterop
@inject IJSRuntime JS

<div class="special-style">
    This component, including the CSS and image required to produce its
    elegant styling, is in an external NuGet package.
    <button @onclick="ChangeLabel">@buttonLabel </button>
</div>

<div class="js-module-message">
</div>

@code {
    string buttonLabel = "Click me";
    private IJSObjectReference _module = null;

    protected async override Task OnInitializedAsync()
    {
        _module = await JS.InvokeAsync<IJSObjectReference>("import", "./_content/TestContentPackage/ComponentFromPackage.razor.js");
        await _module.InvokeVoidAsync("displayMessage", "Hello from module");
    }

    void ChangeLabel()
    {
        buttonLabel = "It works";
    }
}
